package com.braveman.im.ui.activity.message;

/**
 * 作者 昊昊.
 * 年份 2017/11/10.
 * 时间 11:51.
 * 项目名称 hhkj.
 */

import android.content.Intent;
import android.view.View;
import android.widget.EditText;

import com.braveman.im.R;
import com.braveman.im.bean.FriendRemarkBean;
import com.braveman.im.manager.ApiManager;
import com.ht.baselibs.retrofit.NetCallBack;
import com.ht.baselibs.ui.base.BaseActivity;
import com.ht.baselibs.ui.widget.TitleBarView;
import com.ht.baselibs.utils.ActivityUtils;
import com.ht.baselibs.utils.UIUtils;

import retrofit2.Call;
import retrofit2.Response;

/**
 * 好友备注及标签
 */
public class FriendRemarkActivity extends BaseActivity {
    private EditText activityEdtextName;
    private EditText activityEdtextLabel;
    private String friendId;
    private FriendRemarkBean friendRemarkBean;

    @Override
    protected void initTitleBar() {
        mTitleBarView.setTitleText("备注信息").addActions(new TitleBarView.Action(R.color.color_19, "完成") {
            @Override
            public void performAction(View view) {//完成点击
                friendRemarkBean = new FriendRemarkBean();
                ApiManager.getApi().friendRemark(friendId, friendRemarkBean).enqueue(new NetCallBack<FriendRemarkBean>() {
                    @Override
                    protected void onSuccess(Call<FriendRemarkBean> call, Response<FriendRemarkBean> response) {
                        friendRemarkBean = response.body();
                        if (response != null) {
//                            if (activityEdtextName.getText().toString().trim() == null) {
//                                UIUtils.showToast("输入备注");
//                            }
//                            if (activityEdtextLabel.getText().toString().trim() == null) {
//                                UIUtils.showToast("请输入标签");
//                            }
                            friendRemarkBean.friendRemark = activityEdtextName.getText().toString().trim();
                            friendRemarkBean.tagNames = activityEdtextLabel.getText().toString().trim();
                            UIUtils.showToast("成功");
                            ActivityUtils.finishActivity(FriendRemarkActivity.this);
                        }
                    }
                });
            }
        }).setLeftBtnIcon(R.mipmap.back_black).setOnLeftBtnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {//后退点击
                ActivityUtils.finishActivity(FriendRemarkActivity.this);
            }
        });
    }

    @Override
    protected boolean isStaticPage() {
        return true;
    }

    @Override
    protected int initContentView() {
        return R.layout.activity_friend_remark;
    }

    @Override
    protected void initChildView() {
        activityEdtextName = (EditText) findViewById(R.id.activity_edtext_name);
        activityEdtextLabel = (EditText) findViewById(R.id.activity_edtext_label);

    }

    @Override
    protected void initChildData() {

    }

    @Override
    protected void initIntentData(Intent callIntent) {
        friendId = callIntent.getStringExtra("friendId");
    }

    @Override
    protected void setChildViewListener() {

    }
}
